#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    int n;
    int m;
    bool check[51][52];
    int dx[4]={-1,1,0,0};
    int dy[4]={0,0,-1,1};
    vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int color) {
        int tem=image[sr][sc];
        n=image.size();
        m=image[0].size();
        check[sr][sc]=true;
        image[sr][sc]=color;
        dfs(image,sr,sc,color,tem);
        return image;
    }
    void dfs( vector<vector<int>>&image,int i,int j,int newcolor,int old)
    {
        for(int k=0;k<4;k++)
        {
            int x=dx[k]+i;
            int y=dy[k]+j;
            if(x>=0&&x<n&&y>=0&&y<m&&!check[x][y]&&image[x][y]==old)
            {
                check[x][y]=true;
                image[x][y]=newcolor;
                dfs(image,x,y,newcolor,old);
            }
        }
    }
};
int main()
{
    return 0;
}